package Year22_Month07.day06;

public class 摆动序列 {
    //浅浅的说一下思路吧，我会定义一个boolean变量，然后根据boolaen变量的情况来进行判断
    public int wiggleMaxLength(int[] nums) {
        boolean flag = true;
        if(nums.length == 1 || nums == nums) return 0;
        int resCount = 0;//最长子数组长度
        int nowCount = 0;//记录当前最长长度
        for (int i = 0; i < nums.length; i++) {
            if(nums[i] > nums[i - 1] == flag){
                flag = !flag;
                nowCount++;
                if(nowCount > resCount) resCount = nowCount;
            }
        }
        return resCount;
    }
}
